package com.fly.service.Impl;

import com.fly.bean.Circuitry;
import com.fly.bean.Pole;
import com.fly.bean.Task;
//import com.fly.bean.TaskVo;
import com.fly.bean.Users;
import com.fly.mapper.TaskMapper;
import com.fly.service.TaskService;
import com.fly.util.Page;
import com.fly.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TaskServiceImpl implements TaskService {
    @Autowired
    TaskMapper taskMapper;
    //查找所有巡检任务
    @Override
    public List<Task> selectAllTask() {
        return null;
    }

    //条件查询任务
    @Override
    public List<Task> getTaskByConditionS(TaskVoScw taskVoScw) {
        List<Task> tasks = taskMapper.selectTaskByConditionS(taskVoScw);
        return tasks;
    }
    //查询按条件查询的总记录数
    @Override
    public int getTaskCountByConditionS(TaskVoScw taskVoScw) {
        int count = taskMapper.selectTaskCountByConditionS(taskVoScw);
        return count;
    }

    //查询所有线路名和Id
    @Override
    public List<Circuitry> getCircuitryNameAndIdS() {
        List<Circuitry> circuitryNames = taskMapper.selectCircuitryNameAndIdS();
        return circuitryNames;
    }
    //显示所有巡检员名字
    @Override
    public List<Users> getAllInspectorsS() {
        List<Users> users = taskMapper.selectAllInspectorsS();
        return users;
    }

    @Override
    public int addTaskS(TaskVoScw taskVoScw) {
        int row = taskMapper.insertTaskS(taskVoScw);

        return row;
    }

    @Override
    public int getTaskOrderByIdS() {
        int maxTaskId = taskMapper.selectTaskOrderByIdS();
        return maxTaskId;
    }

    @Override
    public int addTURelationS(TaskVoScw taskVoScw) {
        int row = taskMapper.insertTURelationS(taskVoScw);
        return row;
    }

    @Override
    public int addTaskPoleRS(TaskVoScw taskVoScw) {
        int row = taskMapper.insertTaskPoleRS(taskVoScw);
        return row;
    }

    @Override
    public List<Pole> selectPolesByCircuitryIdS(Circuitry circuitry) {

        return taskMapper.selectPolesByCircuitryIdS(circuitry);
    }

    //查询所有所有的任务到分页列表

    @Override
    public List<Task> getAllTasksByPageS(Page page) {
        List<Task> tasks = taskMapper.selectAllTasksByPageS(page);
        return tasks;
    }
//总记录数
    @Override
    public int getTaskTotalCountS(Page page) {
        int count = taskMapper.selectTaskTotalCountS(page);
        return count;
    }

    //通过TaskId查询所分配的巡检员
    @Override
    public List<Users> getInspectorsByTaskIdS(int taskId) {
        List<Users> users = taskMapper.selectInspectorsByTaskIdS(taskId);
        return users;
    }
    //通过线路Id查询起始杆号Id和终止杆号id
    @Override
    public List<Circuitry> getStartAndEndPoleIdByCircuitryIdS(int circuitryId) {
        List<Circuitry> circuitries = taskMapper.selectStartAndEndPoleIdByCircuitryIdS(circuitryId);
        return circuitries;
    }
    //修改巡检任务
    @Override
    public int updateTaskS(TaskVoScw taskVoScw) {

        return taskMapper.updateTaskS(taskVoScw);
    }

    @Override
    public int deleteTaskUserRelS(TaskVoScw taskVoScw) {

        return taskMapper.deleteTaskUserRelS(taskVoScw);
    }

    @Override
    public int addTaskUserRelS(TaskVoScw taskVoScw) {
        return taskMapper.insertTaskUserRelS(taskVoScw);
    }
    //删除task_pole_relation中对应的taskId的数据
    @Override
    public int deleteTaskPoleRel2S(TaskVoScw taskVoScw) {

        return taskMapper.deleteTaskPoleRel2S(taskVoScw);
    }
    //添加task_pole_relation中的数据
    @Override
    public int addTaskPoleRel2S(TaskVoScw taskVoScw) {
        return taskMapper.insertTaskPoleRel2S(taskVoScw);
    }

    //分配任务
    //添加task_user_relation中taskId对应的数据
    @Override
    public int assignInsertTaskUserRel2S(TaskVoScw taskVoScw) {
        return taskMapper.assignInsertTaskUserRel2S(taskVoScw);
    }
    //更改taskId相对应的taskState
    @Override
    public int changeTaskStateByTaskIdS(Integer taskId) {

        return taskMapper.changeTaskStateByTaskIdS(taskId);
    }
    //更改taskId对应的taskState为待分配

    @Override
    public int changeTaskStateUnassigned(Integer taskId) {
        return taskMapper.changeTaskStateUnassigned(taskId);
    }

    //查看任务
    @Override
    public List<CheckTaskStateVoScw> checkMissionSelectTasksS(CheckTaskStateVoScw checkTaskStateVoScw) {

        return taskMapper.checkMissionSelectTasksS(checkTaskStateVoScw);
    }
    //查看任务/查询巡检员
    //查询该任务下的所有巡检员id
    @Override
    public List<Users> checkSelectInspectorsIdByTaskIdS(Task task) {

        return taskMapper.checkSelectInspectorsIdByTaskIdS(task);
    }
    //查看任务中显示分配给任务的起始杆id
    @Override
    public int selectStartPoleIdByTaskId(Integer taskId) {
        return taskMapper.selectStartPoleIdByTaskId(taskId);
    }
    //查看任务中显示分配给任务的终止杆id
    @Override
    public int selectEndPoleIdByTaskId(Integer taskId) {
        return taskMapper.selectEndPoleIdByTaskId(taskId);
    }

    //通过userId查询名字
    @Override
    public Users checkSelectInspectorsByUserIdS(Users users) {

        return taskMapper.checkSelectInspectorsByUserIdS(users);
    }
    //查询该任务下对应线路id的startPoleId和endPoleId
    @Override
    public List<Pole> checkSelectPolesBetweenPoleIdS(TaskPoleVoScw taskPoleVoScw) {

        return taskMapper.checkSelectPolesBetweenPoleIdS(taskPoleVoScw);
    }
    //显示杆详情
    @Override
    public List<PoleVoScw> checkSelectPoleInfosS(Pole pole) {
        return taskMapper.checkSelectPoleInfosS(pole);
    }

    @Override
    public List<CheckRecordsVoErScw> censusSelectTaskInfoByIdS(CheckRecordsVoScw checkRecordsVoScw) {
        return taskMapper.censusSelectTaskInfoByIdS(checkRecordsVoScw);
    }

    @Override
    public int censusCountTaskInfoS(CheckRecordsVoScw checkRecordsVoScw) {
        return taskMapper.censusCountTaskInfoS(checkRecordsVoScw);
    }

    //取消任务
    @Override
    public int updateTaskIsCancelS(Task task) {

        return taskMapper.updateTaskIsCancelS(task);
    }


}
